home *** CD-ROM | disk | FTP | other *** search
- property pScript, pGroupName, pMasterListName, pList2Name, pItemToStringHandler, pIncludeRoll, pList1, pList2, pMasterList, pFunction, pField1, pField2, pFieldObj1, pFieldObj2, pSprite2, pSelection, ancestor
-
- on beginSprite me
- set pScript to "Add-Remove Items Behavior"
- do("global" && pMasterListName)
- set pMasterList to value(pMasterListName)
- do("global" && pList2Name)
- set pList2 to value(pList2Name)
- set pList1 to SubtractLists(pMasterList, pList2)
- set memberName to the name of the member of sprite the spriteNum of me
- case 1 of
- (memberName contains "Available"):
- set pFunction to #field1
- (memberName contains "Selected"):
- set pFunction to #field2
- end case
- case pFunction of
- #field1, #field2:
- set ancestor to new(script "Single State But", the spriteNum of me)
- end case
- case pFunction of
- #field1:
- set pField1 to the number of the member of sprite the spriteNum of me
- set pFieldObj1 to me
- set field1String to GetFieldString(1)
- put field1String into field pField1
- #field2:
- set pField2 to the number of the member of sprite the spriteNum of me
- set pFieldObj2 to me
- set field2String to GetFieldString(2)
- put field2String into field pField2
- end case
- share(me, [#pList1, #pField1, #pField2, #pFieldObj1, #pFieldObj2])
- end
-
- on share me, propsToShare
- set maxSprite to the spriteNum of me
- repeat with n = 1 to count(propsToShare)
- set prop to getAt(propsToShare, n)
- if voidp(getaProp(me, prop)) then
- setaProp(me, prop, FindSpriteProp(maxSprite, [#pScript: pScript, #pGroupName: pGroupName], prop))
- next repeat
- end if
- SetSpriteProp(maxSprite - 1, [#pScript: pScript, #pGroupName: pGroupName], [prop, getaProp(me, prop)])
- end repeat
- end
-
- on MouseUpAction me
- nothing()
- end
-
- on MouseDownAction me
- case pFunction of
- #field1, #field2:
- if the doubleClick then
- MoveLine(me)
- end if
- end case
- end
-
- on MouseEnterAction me
- nothing()
- end
-
- on MouseLeaveAction me
- nothing()
- end
-
- on MoveLine me
- if pFunction = #field1 then
- set theList to pList1
- set theField to pField1
- set otherField to pField2
- else
- set theList to pList2
- set theField to pField2
- set otherField to pField1
- end if
- if not count(theList) then
- exit
- end if
- set clickLine to the mouseLine
- if clickLine < 1 then
- exit
- end if
- set pSelection to [getAt(theList, clickLine)]
- if pFunction = #field1 then
- add(me)
- else
- remove(me)
- end if
- end
-
- on add me
- set listToAdd to the pSelection of pFieldObj1
- set pList1 to SubtractLists(pList1, listToAdd)
- set newList2 to SubtractLists(pMasterList, pList1)
- set theCount to count(pList2)
- repeat with n = theCount down to 1
- deleteAt(pList2, n)
- end repeat
- repeat with listItem in newList2
- append(pList2, listItem)
- end repeat
- set field1String to GetFieldString(1)
- set field2String to GetFieldString(2)
- put field1String into field pField1
- put field2String into field pField2
- set the pList1 of pFieldObj1 to pList1
- set the pList1 of pFieldObj2 to pList1
- end
-
- on remove me
- set listToRemove to the pSelection of pFieldObj2
- set newList2 to SubtractLists(pList2, listToRemove)
- set theCount to count(pList2)
- repeat with n = theCount down to 1
- deleteAt(pList2, n)
- end repeat
- repeat with listItem in newList2
- append(pList2, listItem)
- end repeat
- set pList1 to SubtractLists(pMasterList, pList2)
- set field1String to GetFieldString(1)
- set field2String to GetFieldString(2)
- put field1String into field pField1
- put field2String into field pField2
- set the pList1 of pFieldObj1 to pList1
- set the pList1 of pFieldObj2 to pList1
- end
-
- on GetFieldString whichField
- set fieldString to EMPTY
- if whichField = 1 then
- set theList to pList1
- else
- set theList to pList2
- end if
- repeat with listItem in theList
- set itemString to EMPTY
- do("set itemString =" && pItemToStringHandler & "(listItem)")
- put itemString & RETURN after fieldString
- end repeat
- delete char -30003 of fieldString
- return fieldString
- end
-
- on getPropertyDescriptionList me
- set description to [:]
- addProp(description, #pGroupName, [#default: "Add_Remove_Download_Texts", #format: #string, #comment: "Group Name"])
- addProp(description, #pMasterListName, [#default: "gMasterTexts", #format: #string, #comment: "Variable Name of List of All Items"])
- addProp(description, #pList2Name, [#default: "gDownloadTexts", #format: #string, #comment: "Variable Name of List of Selected Items"])
- addProp(description, #pItemToStringHandler, [#default: "GetTextDescription", #format: #string, #comment: "Name of List-Item-To-String Conversion Handler"])
- addProp(description, #pIncldRoll, [#default: 1, #format: #boolean, #comment: "Buttons Include Rollover"])
- return description
- end
-
- on getBehaviorDescription me
- set endChar to offset("--END OF HEADER", the text of me)
- set endLine to the number of lines in char 1 to endChar of the text of me - 1
- set description to line 1 to endLine of the text of me
- repeat with whichLine = endLine down to 1
- if line whichLine of description = EMPTY then
- delete line whichLine of description
- end if
- end repeat
- delete line 1 of description
- return description
- end
-